//删除空属性，避免null值出现在json中




function deleteEmptyProperty(object){
    for (var i in object) {
        var value = object[i];
        // sodino.com
        // console.log('typeof object[' + i + ']', (typeof value));
        if (typeof value === 'object') {
            if (Array.isArray(value)) {
                if (value.length === 0) {
                    delete object[i];
//                    console.log('delete Array', i);
                    continue;
                }
            }
            deleteEmptyProperty(value);
            if (isEmpty(value)) {
//                console.log('isEmpty true', i, value);
                delete object[i];
//                console.log('delete a empty object');
            }
        } else {
            if (value === '' || value === null || typeof(value) === undefined) {
                delete object[i];
//                console.log('delete ', i);
            } else {
//                console.log('check ', i, value);
            }
        }
    }
}

//判断 为空
function isEmpty(object) {
    for (var name in object) {
        return false;
    }
    return true;
}

module.exports = {
	deleteEmptyProperty:deleteEmptyProperty
  
  };

